//: C19:Nobloat.h
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Templatized InheritStack.cpp
#ifndef NOBLOAT_H
#define NOBLOAT_H
#include "Stack4.h"

template<class T>
class NBStack : public Stack
{
public:
    void push(T* str) {
        Stack::push(str);
    }
    T* peek() const {
        return (T*)Stack::peek();
    }
    T* pop() {
        return (T*)Stack::pop();
    }
    ~NBStack();
};

// Defaults to heap objects & ownership:
template<class T>
NBStack<T>::~NBStack()
{
    T* top = pop();
    while (top) {
        delete top;
        top = pop();
    }
}
#endif // NOBLOAT_H ///:~
